/**
 * Created by chenzui on 2017/4/20.
 */
var $btnSubmit = $('#submitBtn');
var $addofferCancelBtn = $('#addoffer-cancelBtn');
function commit() {
    debugger;
    var offerIds = $('[name="duallistbox_demo1[]"]').val();
    var marketId = $('#market2Offers').attr("data-market-id");
    var idStr="";
    $.each(offerIds,function (i,o) {
        idStr += o+",";
    })
    var param = {
        "offerIds":idStr.substr(0,idStr.length-1),
        "marketId":marketId
    }
    Ajax.ajax({
        url: "/market/addOfferRela",
        data: param,
        type: "POST",
        dataType: 'json',
        success: function (res) {
            if (res.resultCode == 0) {
                // alert(res.data);
                alert(res.data);
                $('#mainframe').load('/shop/offer/market/list.html');
            } else {
                alert(res.data);
            }
        },
        error: function(){
            alert("操作失败");
        }
    });
}

$(function () {
     $btnSubmit.on('click',function () {
         commit();
     });
    $addofferCancelBtn.on('click',function () {
        $('#mainframe').load('/shop/offer/market/list.html');
    });
})